#include <stdio.h>
using namespace std;

int oh, om;
int ah, am;
int n;
int sum;
int ot, at;

int main() {
	while (scanf("%d", &n)!=EOF) {
		sum=0;

		for (int i=0; i<n; i++) {
			scanf("%d %d %d %d", &oh, &om, &ah, &am);
			ot=60*oh+om;
			at=60*ah+am;

			if (at-ot>0)
				sum+=(at-ot);
		}
		printf("%d\n", sum/n);
	}

	return 0;
}
